home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / programming / amos / amoslist-0195.lzh / AMOSLIST / text0048.txt < prev    next >
Encoding:
Text File  |  1995-02-01  |  4.7 KB  |  151 lines

  1. On Sun, 1 Jan 1995, John Carpenter wrote:
  2.  
  3. > Finally...
  4. > I have (half) written a paint package, but am experiencing several
  5. > problems with it.  (surprisingly)
  6. > 1) Can anyone tell me the formula for a parabola?  Or preferably, can
  7. > anyone tell me how to write a curve tool like the one in Deluxe paint?
  8. >
  9.  
  10.     yup... here is mine from my paint program... it works identical
  11.   to that of DeluxePaints...  If you want to understand the Math look
  12.   up Bezier Curves... this one use's a 3-point bezeir curve...
  13.  
  14. Procedure _BEZIER_BRUSH[PX0,PY0,PX1,PY1,PX2,PY2]
  15. '
  16. '  PX0,PY0 --> one end point
  17. '  PX1,PY1 --> the middle point  (normally the current mouse co-ords)
  18. '  PX2,PY2 --> the other end point
  19. '
  20. ' this recomputes the middle point so that the curve actually goes 
  21. ' through the mouse pointer.... obtained from equating cx#=px1 and 
  22. ' cy#=py1 and picking t=0.5 then solving cx,cy for px1,py1.
  23. ' Note: the 'DRAW_LINE2[]' procedure just draws a line but uses the
  24. ' current brush the user has selected.
  25. '
  26.  
  27. PX1=2*PX1-PX0/2-PX2/2
  28. PY1=2*PY1-PY0/2-PY2/2
  29.  
  30. _STEP#=0.1
  31.  
  32. For T#=0 To 1.0 Step _STEP#
  33.  
  34.    CX#=PX0*(1-T#)^2+PX1*(2*T#*(1-T#))+PX2*T#*T#
  35.    CY#=PY0*(1-T#)^2+PY1*(2*T#*(1-T#))+PY2*T#*T#
  36.  
  37.    N#=T#+_STEP#
  38.  
  39.    CXN#=PX0*(1-N#)^2+PX1*(2*N#*(1-N#))+PX2*N#*N#
  40.    CYN#=PY0*(1-N#)^2+PY1*(2*N#*(1-N#))+PY2*N#*N#
  41.  
  42.    _DRAW_LINE2[CX#,CY#,CXN#,CYN#]
  43.  
  44. Next 
  45.  
  46. '
  47. End Proc
  48.  
  49.     I use this as the second step in a 2 step process for drawing
  50.    curves in my paint program... first I call my 'Draw Line' command
  51.    then I call 'Draw Bezeir' command with 2 endpoints of the curve
  52.    obtained from the 'Draw Line' and the middle point coming from 
  53.    current mouse co-ords.
  54.  
  55.  
  56. > 2) What I want to do, for example, is pick up a circle of colour 0 from
  57. > a background of colour 1 as a BOB, like:
  58. >        ______
  59. >       |  __  |<--colour 1
  60. >       | /  \ |
  61. >       | \__/<|---colour 0
  62. >       |______|
  63. > BUT I would like colour 1 to be transparent and NOT colour 0!  I found a
  64. > machine code procedure called MAKE_MASK on an AmosPro Productivity disk
  65. > and tried to use that in conjunction with NO MASK but without success.
  66.  
  67.     yup I also wrote this for my paint program too!  It is included
  68.   in the Amos Procedure Library on Aminet... ( AMINET:dev/amos/ProbLib3.lha
  69.   .. or really close ) I belive its called MAKE_ICONMASK[]... if you don't
  70.   have ftp access I will send the procedure to ya...
  71.  
  72.     this one took me about a week to figure out how to code...  I explain
  73.   the algorithm quite well in the procedure... 
  74.  
  75.     this is in marp also...
  76.  
  77.  
  78. > 3) I presume there's no way to REDIM an array is there?
  79.  
  80.     Nope... but you can always you Exec's Alloc routines to dynamicaly
  81.   allocate and free mem... 
  82.  
  83. > 4) Or SET BUFFER within a program?  I want to have a list of fonts but,
  84. > since I don't have a hard drive, I have hardly any.  When I gave the
  85. > program to a friend it said "out of variable space" or something.  Do I
  86. > just whack it up high and hope for the best?  If so, is there a way of
  87. > telling a maximum number of fonts that the buffer would hold?  I don't
  88. > think I can do an interface ActiveList directly from the FONT$() array
  89. > can I??
  90.  
  91.     I had this exact same problem... I just set a limit to a maxium of
  92.   500 fonts... I wrote a full Font Requester using Pros Interface Language..
  93.   you can have it if you want it... 
  94.  
  95.     marp will let you call reqtools fontrequester easily to get by
  96.   this problem easily...
  97.  
  98. > 5) Is there a faster version of PLOT and POINT as I'm doing "image
  99. > processing" (sort of..) in the program and it's REALLY slow.  I have
  100. > seen an image processor I think is in Amos (because you can Ami+A it
  101. > into Wbench) and it makes mine look foolish by being so fast - how does
  102. > it do it?
  103.  
  104.     Here you will have to be more specific... if you are doing "real"
  105.   digital image processing (which I only know a little about at the moment
  106.   I have taken a course in Digital Signal Processing (the pre requsite to
  107.   the Imag procressing one) but it is basically 2-d signal processing)...
  108.  
  109.     In the "real" processing... you basically have to convolve a 
  110.   filter with a signal... ie. y = x * h (*=convolution (polynomial 
  111.   multiplication) or Y=X*H (*=normal multiplication) in the frequency
  112.   domain...  I may be taking the 'Image' processing course this semester
  113.   (it depends on whether I can get in) so I may be able to help a bit more
  114.   in a month  :)
  115.     
  116.  
  117.  
  118. > --
  119. > I think that'll have to do for now, although I'm sure I'll think of some
  120. > more soon!  Sorry about this, I hope you don't mind all this crap.  
  121.  
  122.     I don't :)... this is a god way to learn... 
  123.  
  124. > If
  125. > you can help with any of it I will be incredibly grateful as many of
  126. > these things have plagued me for AGES!!!
  127. > Thanks..
  128.  
  129.     your welcome... 
  130.  
  131.                                 mike
  132.  
  133.  
  134. > -- 
  135. > Semprini
  136. > (Oh yeah...happy new year etc etc..)
  137.  
  138.